#ifndef __VSDL_COLLISION_H__
#define __VSDL_COLLISION_H__

#include <SDL/SDL.h>
#include <list>
#include "VSDL_point.h"
#include "VSDL_RGB.h"

class VSDL_CollisionBox{
private:
	int id;
	VSDL_Point centerXY; //Basic coordinates used for moveBoxXXX()
	SDL_Rect box;
	void RectXY();
public:
	VSDL_CollisionBox();
	VSDL_CollisionBox(VSDL_Point centerXY); //For temproary variable
	VSDL_CollisionBox(VSDL_Point centerXY, int boxWidth, int boxHeight); //For temproary variable
	VSDL_CollisionBox(VSDL_Point centerXY, int boxWidth, int boxHeight, int id); //For temproary variable
	void SetBoxSize(int boxWidth, int boxHeight);
	void MoveBoxAbs(VSDL_Point point); //For temproary variable
	void MoveBoxRel(VSDL_Point relXY); //For temproary variable
	const VSDL_Point &GetCenterPoint() const;
	void SetId(int id);
	int GetId();
	void GetBoxSize(int &boxWidth, int &boxHeight);
	bool IsCollided(VSDL_CollisionBox &destBox);
	void Blit(SDL_Surface *destSurf, VSDL_RGB color); //Only for debugging purpose
};

class VSDL_CollisionHandle{
private:
	std::list<VSDL_CollisionBox *> collisionBoxes;
	std::list<VSDL_CollisionBox *> collidedBoxes;  
public:
	void Reset(); 
	void ClearCollidedList();//Empty list of collided boxes
	void AddCollisionBox(VSDL_CollisionBox *box);	
	void DeleteCollisionBox(VSDL_CollisionBox *box);
	void AddCollisionBoxes(VSDL_CollisionBox *boxes, int nBoxes);
	void MoveBoxesRel(VSDL_Point point);
	bool DetectCollision(VSDL_CollisionHandle &handle);
	int GetCollidedBoxesCount();
	VSDL_CollisionBox *GetCollidedBox(); //This function should be used in a loop.When it returns NULL,no other collided boxes.
	const std::list<VSDL_CollisionBox *> &GetCollidedBoxes();
	void Blit(SDL_Surface *destSurf, VSDL_RGB color); //Only for debugging purpose
};
#endif /*__VSDL_COLLISION_H__*/
